package com.shrcl.engineerprocess.domain.impl;

import com.google.common.base.Objects;
import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.EngineerLevelSalary;
import com.shrcl.engineerprocess.domain.EngineerLevelSalaryDAO;
import com.shrcl.engineerprocess.domain.impl.EngineerLevelSalaryImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.EngineerLevelSalaryDAO")
public class EngineerLevelSalaryDAOImpl extends BaseDAOService<EngineerLevelSalary> implements EngineerLevelSalaryDAO {
  public EngineerLevelSalary getEngineerLevelSalaryByLevel(final EngineerLevel engineerLevel) {
    EngineerLevelSalary _xblockexpression = null;
    {
      IGenericQuery<EngineerLevelSalary> query=getObjectFactory().createGenericQuery(EngineerLevelSalary.class,"select e from com.shrcl.engineerprocess.domain.impl.EngineerLevelSalaryImpl as e   where ((e.level) = (:engineerLevel)) and  e.active = 1      ").setParameter("engineerLevel",engineerLevel);
      EngineerLevelSalary els = query.uniqueResult();
      boolean _equals = Objects.equal(els, null);
      if (_equals) {EngineerLevelSalary engineerLevelSalary=EngineerLevelSalaryImpl.create(getObjectFactory());
        final Procedure1<EngineerLevelSalary> _function = new Procedure1<EngineerLevelSalary>() {
            public void apply(final EngineerLevelSalary it) {
              it.setLevel(engineerLevel);
            }
          };
        EngineerLevelSalary _doubleArrow = ObjectExtensions.<EngineerLevelSalary>operator_doubleArrow(engineerLevelSalary, _function);
        els = _doubleArrow;
      }
      _xblockexpression = (els);
    }
    return _xblockexpression;
  }
}
